package com.cqcomponents.components;

import org.apache.commons.lang.StringUtils;

import com.cqcomponents.annotations.JcrPropertyInjection;

public class Button extends BaseComponent {

	enum ButtonSize {
		xs, sm, lg, dt
	}

	enum ButtonStyle {
		primary, info, success, warning, danger, inverse, link, dt
	}

	private String text;
	private ButtonSize size;
	private ButtonStyle style;

	@JcrPropertyInjection
	public void setStyle(String style) {
		try {
			this.style = ButtonStyle.valueOf(style);
		} catch (Exception e) {
			this.logger.warn("Could not set button style", e);
		}
	}

	public String getStyle() {
		return this.style != null ? this.style.name() : null;
	}

	@JcrPropertyInjection
	public void setSize(String size) {
		try {
			this.size = ButtonSize.valueOf(size);
		} catch (Exception e) {
			this.logger.warn("Could not set button size", e);
		}
	}

	public String getSize() {
		return this.size != null ? this.size.name() : null;
	}

	@JcrPropertyInjection
	public void setText(String text) {
		this.text = text;
	}

	public String getText() {
		return this.text;
	}

	@Override
	public String toString() {
		return "Button:{text:" + this.text + ", size:" + this.size + ", style:"
				+ this.style + "}";
	}

	@Override
	public boolean getHasContent() {
		return StringUtils.isNotBlank(this.text);
	}

}
